<!DOCTYPE html>
<html>

<head>

	<meta charset="UTF-8">
	<meta name="copyright" content="www.apicloud.com" />
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>舆情工作平台</title>
	<link rel="stylesheet" type="text/css" href="../css/login.css" />
	<style type="text/css">
		body,
		html {
			width: 100%;
			height: 50px;
			background: #fff;
			margin: 0px;
			padding: 0px;
		}

		.back {
			border-top: 1px solid #cdcdcd;
			/*display:-webkit-flex;
	           display:-webkit-box;
	           display:-moz-box;
	           display:flex;
	           display:box;*/
			width: 100%;
			float: right;
			height: 50px;
			overflow: hidden;
		}

		.back>* {
			display: block;
			-webkit-flex: 1;
			flex: 1;
		}

		.back>span>img {
			vertical-align: middle;
			padding: 5px 12px 0px 12px;
		}

		.back>span {
			float: right;
			font-size: 10px;
			color: #8a8a8a;
			text-align: center;
			font-family: "SimSun";
			/*width:128px;*/
		}
		/*.back>span{ display:block; float:left; width:16.5%; padding-left:20px; height:50px; padding-top:5px;  background:url(../image/btn/cz1.png)  no-repeat center ; background-size:auto 90%;}*/
	</style>
</head>

<body>
	<div id="back" class="back">
		<span style="float:left" id="goback" tapmode="buyhover" onclick="api.closeWin();">
                <img src="../image/btn/left_back.png" height="46">
           </span>
		<!--<span id="kong">
                <img src="../image/btn/kong2.png" height="46">
           </span>-->
		<span id="fx" tapmode="buyhover" onclick="goto_showMoreMenuFun(99)"><img src="../image/btn/fx@2x.png" height="26"><br>分享</span>
		<span id="shangbao" tapmode="buyhover" onclick="goto_setreport()"></span>


		<span id="sc" tapmode="buyhover" onclick="goto_userFavoriteFun()"></span>
		<span id="bohui" tapmode="buyhover" onclick="goto_infoFun(4)"></span>
		<!-- <span id="cz" tapmode="buyhover" onclick="goto_showMoreMenuFun(1)"></span> -->
		<span id="chehui" tapmode="buyhover" onclick="goto_setrecall()"></span>

		<span id="fankui" tapmode="buyhover" onclick="goto_infoFun(2)"></span>
		<span id="shenhe" tapmode="buyhover" onclick="goto_infoFun(3)"></span>
		<span id="zhuanban" tapmode="buyhover" onclick="goto_infoFun(1)"></span>

	</div>
	<!-------------------分享信息---------------------------->
	<input id="url" type="hidden" value="" />
	<input id="title" type="hidden" value="" />
	<input id="abstract_content" type="hidden" value="" />
	<!-------------------分享信息---------------------------->
	<!-------------------信息状态---------------------------->
	<input id="is_collect" type="hidden" value="" />
	<input id="is_pass" type="hidden" value="" />
	<input id="pass_status" type="hidden" value="" />
	<input id="deal_status" type="hidden" value="" />
	<input id="forwarding_status" type="hidden" value="" />

	<!-------------------信息状态---------------------------->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script>

<script type="text/javascript">
	apiready = function() {
		$("#url").val(api.pageParam.url);
		$("#title").val(api.pageParam.title);
		$("#abstract_content").val(api.pageParam.abstract_content);

		$("#is_collect").val(api.pageParam.is_collect);
		$("#is_pass").val(api.pageParam.is_pass);
		$("#pass_status").val(api.pageParam.pass_status);
		$("#deal_status").val(api.pageParam.deal_status);

		$("#forwarding_status").val(api.pageParam.forwarding_status);

		if (api.pageParam.is_deal == "1") {

			if (api.pageParam.is_fankui == "1") {
				$("#fankui").html('<img src="../image/btn/fankui@2x1.png" height="28"><br>处置反馈');
			} else {
				$("#fankui").html('');
				$('#fankui').unbind("click");
			}

			if (api.pageParam.is_shenhe == "1") {
				$("#shenhe").html('<img src="../image/btn/dealover@2x.png" height="28"><br>审核');
			} else {
				$("#shenhe").html('');
				$('#shenhe').unbind("click");
			}

			if (api.pageParam.is_chehui == "1") {
				$("#chehui").html('<img src="../image/btn/tuihui@2x.png" height="28"><br>撤回');
			} else {
				$("#chehui").html('');
				$('#chehui').unbind("click");
			}


			if (api.pageParam.is_zhuanban == "1") {
				$("#zhuanban").html('<img src="../image/btn/zhuanban@2x.png" height="28"><br>转办');
			} else {
				$("#zhuanban").html('');
				$('#zhuanban').unbind("click");
			}
			if (api.pageParam.is_bohui == "1") {
				$("#bohui").html('<img src="../image/btn/bohui@2x.png" height="28"><br>驳回');
			} else {
				$("#bohui").html('');
				$('#bohui').unbind("click");
			}
		} else {
			$("#cz").html('');
			$('#cz').unbind("click");
		}
		if (api.pageParam.is_collect == "未收藏") {
			$("#sc").html('<img src="../image/btn/collected@2x.png" height="28"><br>收藏');
		} else if (api.pageParam.is_collect == "已收藏") {
			$("#sc").html('<img src="../image/btn/already_collected@2x.png" height="28"><br>已收藏');
		} else {
			$("#sc").html('');
			$('#sc').unbind("click");
		}

		$("#fx").html('<img src="../image/btn/fx@2x.png" height="28"><br>分享');
	}

	function goto_userFavoriteFun() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误'
			});
			return;
		}
		api.showProgress({
			style: 'default',
			animationType: 'fade',
			title: '',
			text: '',
			modal: false
		});

		var MD5 = new Hashes.MD5;
		var access_token = Alpe_getLocalStorge("access_token");
		var admin_id = Alpe_getLocalStorge("admin_id");
		var sign = MD5.hex(access_token + admin_id + infoID + 'datas/setCollect1.0syjqingbao');

		var url = Alpe_ApiUrl + 'r=datas/setCollect&access_token=' + access_token + '&admin_id=' + admin_id +
			'&message_id=' + infoID +
			'&v=1.0&sign=' + sign;
		api.ajax({
			url: url,
			method: 'get',
			cache: false,
			timeout: 30,
			dataType: 'json'
		}, function(ret, err) {
			console.log($api.jsonToStr(ret));
			if (ret) {
				if (ret.success == "101") {
					var is_collect = $("#is_collect").val();
					if (is_collect == "未收藏") {
						$("#sc").html('<img src="../image/btn/already_collected@2x.png" height="28"><br>已收藏');
						$("#is_collect").val("已收藏");

					} else {
						$("#sc").html('<img src="../image/btn/collected@2x.png" height="28"><br>收藏');
						$("#is_collect").val("未收藏");
					}
				}
				api.toast({
					msg: ret.message,
					duration: 2000,
					location: 'middle'
				});
				api.hideProgress();
			} else {
				api.alert({
					title: '系统提示',
					msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
				});
				api.hideProgress();
			}
		});
	}

	function goto_infoFun(goType) {
		var infoID = api.pageParam.infoID;
		var is_area_admin = api.pageParam.is_area_admin;
		var deal_status = api.pageParam.deal_status;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误'
			});
			return;
		}
		api.openWin({
			name: 'yq_listDetail_Deal',
			url: './yq_listDetail_Deal.html',
			delay: 300,
			pageParam: {
				infoID: infoID,
				goType: goType,
				is_area_admin: is_area_admin,
				deal_status: deal_status
			},
			bounces: false,
		});
	}

	function goto_setrecall() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误4'
			});
			return;
		}
		var deal_status = "2";
		api.confirm({
			title: '确认是否提交',
			msg: '撤回后信息会改为未处置状态,确定撤回吗？',
			buttons: ['确定', '取消']
		}, function(ret, err) {
			if (ret.buttonIndex == 1) {
				api.showProgress({
					style: 'default',
					animationType: 'fade',
					title: '',
					text: '',
					modal: false
				});

				var MD5 = new Hashes.MD5;
				var access_token = Alpe_getLocalStorge("access_token");
				var admin_id = Alpe_getLocalStorge("admin_id");
				var sign = MD5.hex(access_token + admin_id + infoID + 'datas/setDeal1.0syjqingbao');

				var url = Alpe_ApiUrl + 'r=datas/setRecall&access_token=' + access_token + '&admin_id=' + admin_id +
					'&message_id=' + infoID +
					'&v=1.0&sign=' + sign;
				console.log(url);
				api.ajax({
					url: url,
					method: 'post',
					cache: false,
					returnAll: false,
					dataType: 'json'
				}, function(ret, err) {
					console.log($api.jsonToStr(ret));
					if (ret) {
						api.hideProgress();
						api.toast({
							msg: ret.message,
							duration: 2000,
							location: 'middle'
						});
						if (ret.success == "101") {
							var status = $("#status").val();
							/*注册已经处理的事件，刷新详细页面*/
							api.sendEvent({
								name: 'Alpe_Event_yq_dosomething',
								extra: {
									keyID: 'alpenlicebe',
									message_id: infoID,
									status: status
								}
							});
							// setTimeout(function() {
							// 	api.closeWin();
							// }, 900);
						}
					} else {
						api.alert({
							title: '系统提示',
							msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
						});
						api.hideProgress();
					}
				});
			}
		});
	}

	function goto_showMoreMenuFun(menuType) {

		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误'
			});
			return;
		}
		var url = $("#url").val();
		var title = $("#title").val();
		var abstract_content = $("#abstract_content").val();

		var is_pass = $("#is_pass").val(); //0可以申请无效，1已申请无效
		var pass_status = $("#pass_status").val(); //0审核中，1通过，2不通过
		var deal_status = $("#deal_status").val(); //当前处置状态，0未处置，1处置中，2处置完毕
		var forwarding_status = $("#forwarding_status").val(); //当0是 没有转办    1是已转办 ，2是已处理完


		if (1 == menuType || 2 == menuType) {
			if (99 == is_pass || 99 == pass_status || 99 == deal_status || 99 == forwarding_status) {
				return;
			}
		}
		if (99 == menuType) {
			if (url == '') {
				api.alert({
					title: '系统提示',
					msg: "信息无原文链接，请使用截图或复制文字的方式分享"
				});
				return false;
			}
			api.openFrame({
				name: 'share',
				url: './share.html',
				rect: {
					x: 0,
					y: 0,
					w: "auto",
					h: "auto"
				},
				pageParam: {
					newsTitle: title,
					newsDesc: abstract_content,
					newsUrl: url,
					newsImg: ''
				},
				bounces: false,
				bgColor: 'rgba(0,0,0,0.5)'
			});
		} else {
			if (2 == menuType) {
				if (api.pageParam.is_area_admin != 0) {
					api.alert({
						title: '系统提示',
						msg: '此功能仅限市级处置人操作'
					});
					return;
				}
			}

			api.openFrame({
				name: 'yq_menuBottomMore',
				url: './yq_menuBottomMore.html',
				rect: {
					x: 0,
					y: 0,
					w: "auto",
					h: "auto"
				},
				pageParam: {
					infoID: infoID,
					menuType: menuType,

					is_pass: is_pass,
					pass_status: pass_status,
					deal_status: deal_status,
					forwarding_status: forwarding_status,

					url: url,
					title: title,
					abstract_content: abstract_content
				},
				vScrollBarEnabled: true,
				hScrollBarEnabled: false,
				scaleEnabled: true,
				reload: true,
				bounces: false,
			});
		}
	}
</script>

</html>
